home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 August / Chip_2001-08_cd2.bin / kancelar / text2pdf / SETUPT2P.EXE / {app} / pdfmain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-04-17  |  13.9 KB  |  454 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
  3. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
  4. Begin VB.Form pdfmain 
  5.    Caption         =   "FyTek's Text to PDF Converter - Sample Application"
  6.    ClientHeight    =   7515
  7.    ClientLeft      =   165
  8.    ClientTop       =   735
  9.    ClientWidth     =   7695
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   7515
  12.    ScaleWidth      =   7695
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin VB.CheckBox fntItalic 
  15.       Caption         =   "Italics"
  16.       Height          =   255
  17.       Left            =   6240
  18.       TabIndex        =   8
  19.       Top             =   5520
  20.       Width           =   975
  21.    End
  22.    Begin VB.CheckBox fntBold 
  23.       Caption         =   "Bold"
  24.       Height          =   255
  25.       Left            =   6240
  26.       TabIndex        =   7
  27.       Top             =   5160
  28.       Width           =   975
  29.    End
  30.    Begin VB.ComboBox numCols 
  31.       Height          =   315
  32.       ItemData        =   "pdfmain.frx":0000
  33.       Left            =   1560
  34.       List            =   "pdfmain.frx":000D
  35.       Style           =   2  'Dropdown List
  36.       TabIndex        =   4
  37.       Top             =   5640
  38.       Width           =   2055
  39.    End
  40.    Begin VB.ComboBox fntAlign 
  41.       Height          =   315
  42.       ItemData        =   "pdfmain.frx":0031
  43.       Left            =   1560
  44.       List            =   "pdfmain.frx":0041
  45.       Style           =   2  'Dropdown List
  46.       TabIndex        =   3
  47.       Top             =   5160
  48.       Width           =   2055
  49.    End
  50.    Begin VB.ComboBox fntPoint 
  51.       Height          =   315
  52.       ItemData        =   "pdfmain.frx":0063
  53.       Left            =   5040
  54.       List            =   "pdfmain.frx":009D
  55.       Style           =   2  'Dropdown List
  56.       TabIndex        =   6
  57.       Top             =   5640
  58.       Width           =   1095
  59.    End
  60.    Begin VB.ComboBox fntNum 
  61.       Height          =   315
  62.       ItemData        =   "pdfmain.frx":00D7
  63.       Left            =   4080
  64.       List            =   "pdfmain.frx":00E4
  65.       Style           =   2  'Dropdown List
  66.       TabIndex        =   5
  67.       Top             =   5160
  68.       Width           =   2055
  69.    End
  70.    Begin VB.CheckBox chkPreview 
  71.       Caption         =   "Preview"
  72.       Height          =   375
  73.       Left            =   4080
  74.       TabIndex        =   9
  75.       Top             =   6480
  76.       Value           =   1  'Checked
  77.       Width           =   1335
  78.    End
  79.    Begin MSComctlLib.ImageList ImageList1 
  80.       Left            =   360
  81.       Top             =   5040
  82.       _ExtentX        =   1005
  83.       _ExtentY        =   1005
  84.       BackColor       =   -2147483643
  85.       ImageWidth      =   16
  86.       ImageHeight     =   16
  87.       MaskColor       =   12632256
  88.       _Version        =   393216
  89.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  90.          NumListImages   =   3
  91.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  92.             Picture         =   "pdfmain.frx":0109
  93.             Key             =   ""
  94.          EndProperty
  95.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  96.             Picture         =   "pdfmain.frx":0225
  97.             Key             =   ""
  98.          EndProperty
  99.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  100.             Picture         =   "pdfmain.frx":033D
  101.             Key             =   ""
  102.          EndProperty
  103.       EndProperty
  104.    End
  105.    Begin MSComctlLib.Toolbar Toolbar1 
  106.       Align           =   1  'Align Top
  107.       Height          =   570
  108.       Left            =   0
  109.       TabIndex        =   16
  110.       Top             =   0
  111.       Width           =   7695
  112.       _ExtentX        =   13573
  113.       _ExtentY        =   1005
  114.       ButtonWidth     =   873
  115.       ButtonHeight    =   953
  116.       Appearance      =   1
  117.       Style           =   1
  118.       ImageList       =   "ImageList1"
  119.       _Version        =   393216
  120.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  121.          NumButtons      =   5
  122.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  123.             Caption         =   "New"
  124.             ImageIndex      =   1
  125.          EndProperty
  126.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  127.             ImageIndex      =   2
  128.             Style           =   3
  129.          EndProperty
  130.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  131.             Caption         =   "Open"
  132.             ImageIndex      =   2
  133.          EndProperty
  134.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  135.             Caption         =   "Save"
  136.             ImageIndex      =   3
  137.          EndProperty
  138.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  139.             Style           =   3
  140.          EndProperty
  141.       EndProperty
  142.    End
  143.    Begin VB.TextBox txtEditor 
  144.       BeginProperty Font 
  145.          Name            =   "Courier New"
  146.          Size            =   9
  147.          Charset         =   0
  148.          Weight          =   400
  149.          Underline       =   0   'False
  150.          Italic          =   0   'False
  151.          Strikethrough   =   0   'False
  152.       EndProperty
  153.       Height          =   3315
  154.       Left            =   5
  155.       MultiLine       =   -1  'True
  156.       ScrollBars      =   3  'Both
  157.       TabIndex        =   11
  158.       Top             =   660
  159.       Width           =   6900
  160.    End
  161.    Begin VB.TextBox infile 
  162.       Height          =   285
  163.       Left            =   1560
  164.       TabIndex        =   1
  165.       Top             =   4260
  166.       Width           =   5415
  167.    End
  168.    Begin VB.CommandButton cmdInput 
  169.       Caption         =   "..."
  170.       Height          =   255
  171.       Left            =   1200
  172.       TabIndex        =   12
  173.       Top             =   4260
  174.       Width           =   315
  175.    End
  176.    Begin MSComctlLib.StatusBar StatusBar1 
  177.       Align           =   2  'Align Bottom
  178.       Height          =   375
  179.       Left            =   0
  180.       TabIndex        =   14
  181.       Top             =   7140
  182.       Width           =   7695
  183.       _ExtentX        =   13573
  184.       _ExtentY        =   661
  185.       _Version        =   393216
  186.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  187.          NumPanels       =   1
  188.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  189.             Object.Width           =   8819
  190.             MinWidth        =   8819
  191.          EndProperty
  192.       EndProperty
  193.    End
  194.    Begin MSComDlg.CommonDialog CommonDialog1 
  195.       Left            =   960
  196.       Top             =   5040
  197.       _ExtentX        =   847
  198.       _ExtentY        =   847
  199.       _Version        =   393216
  200.    End
  201.    Begin VB.CommandButton cmdOutput 
  202.       Caption         =   "..."
  203.       Height          =   255
  204.       Left            =   1200
  205.       TabIndex        =   13
  206.       Top             =   4680
  207.       Width           =   315
  208.    End
  209.    Begin VB.CommandButton go 
  210.       Caption         =   "Create PDF"
  211.       Height          =   375
  212.       Left            =   2520
  213.       TabIndex        =   10
  214.       Top             =   6480
  215.       Width           =   1335
  216.    End
  217.    Begin VB.TextBox outfile 
  218.       Height          =   285
  219.       Left            =   1560
  220.       TabIndex        =   2
  221.       Top             =   4680
  222.       Width           =   5415
  223.    End
  224.    Begin VB.Label fntLabel 
  225.       Alignment       =   1  'Right Justify
  226.       Caption         =   "Point Size"
  227.       Height          =   255
  228.       Left            =   4080
  229.       TabIndex        =   17
  230.       Top             =   5670
  231.       Width           =   855
  232.    End
  233.    Begin VB.Label lab_infile 
  234.       Alignment       =   1  'Right Justify
  235.       Caption         =   "Input File"
  236.       Height          =   255
  237.       Left            =   120
  238.       TabIndex        =   15
  239.       Top             =   4260
  240.       Width           =   975
  241.    End
  242.    Begin VB.Label lab_outfile 
  243.       Alignment       =   1  'Right Justify
  244.       Caption         =   "Output File"
  245.       Height          =   255
  246.       Left            =   120
  247.       TabIndex        =   0
  248.       Top             =   4680
  249.       Width           =   975
  250.    End
  251.    Begin VB.Menu mnuFile 
  252.       Caption         =   "&File"
  253.       Begin VB.Menu mnuNewScript 
  254.          Caption         =   "&New Script"
  255.       End
  256.       Begin VB.Menu mnuOpenScript 
  257.          Caption         =   "&Open Script"
  258.       End
  259.       Begin VB.Menu mnuSpacer1 
  260.          Caption         =   "-"
  261.       End
  262.       Begin VB.Menu mnuSave 
  263.          Caption         =   "&Save"
  264.       End
  265.       Begin VB.Menu mnuSaveAs 
  266.          Caption         =   "Save &As"
  267.       End
  268.       Begin VB.Menu mnuSpacer2 
  269.          Caption         =   "-"
  270.       End
  271.       Begin VB.Menu mnuCreatePDF 
  272.          Caption         =   "&Create PDF"
  273.       End
  274.       Begin VB.Menu mnuSpacer3 
  275.          Caption         =   "-"
  276.       End
  277.       Begin VB.Menu Exit 
  278.          Caption         =   "E&xit"
  279.       End
  280.    End
  281. Attribute VB_Name = "pdfmain"
  282. Attribute VB_GlobalNameSpace = False
  283. Attribute VB_Creatable = False
  284. Attribute VB_PredeclaredId = True
  285. Attribute VB_Exposed = False
  286. Public CancelUnload As Boolean
  287. Private Sub cmdInput_Click()
  288. OpenScript
  289. End Sub
  290. Private Sub cmdOutput_Click()
  291. CommonDialog1.DefaultExt = ".txt"
  292. CommonDialog1.Filter = "Adobe Acrobat|*.pdf"
  293. CommonDialog1.ShowOpen
  294. outfile.Text = CommonDialog1.FileName
  295. End Sub
  296. Private Sub Exit_Click()
  297. Unload Me
  298. End Sub
  299. Private Sub Form_Load()
  300. bolScriptNeedsSaving = False
  301. Toolbar1.Buttons(4).Enabled = False
  302. fntAlign.ListIndex = 0
  303. fntNum.ListIndex = 0
  304. fntPoint.ListIndex = 3
  305. numCols.ListIndex = 0
  306. End Sub
  307. Private Sub Form_Resize()
  308. txtEditor.Width = pdfmain.Width - 100
  309. End Sub
  310. Public Sub Form_Unload(Cancel As Integer)
  311. CheckForSave
  312. If CancelUnload Then Cancel = 1
  313. End Sub
  314. Private Sub go_Click()
  315. CreatePDF
  316. End Sub
  317. Public Sub OpenScript()
  318. CommonDialog1.InitDir = App.Path
  319. CommonDialog1.DefaultExt = ".txt"
  320. CommonDialog1.Filter = "Text Files|*.txt"
  321. CommonDialog1.ShowOpen
  322. If CommonDialog1.FileName = "" Then Exit Sub
  323. strScriptFilePath = CommonDialog1.FileName
  324. infile.Text = strScriptFilePath
  325. StatusBar1.Panels(1).Text = "Opening " & infile.Text
  326. If Not (FileSys.FileExists(infile.Text)) Then
  327.     MsgBox "File does not exist"
  328.     Exit Sub
  329. End If
  330. Open infile.Text For Input As #1
  331. Do Until EOF(1)
  332.     Line Input #1, strLineInput
  333.     If Not EOF(1) Then
  334.         strFileInput = strFileInput & strLineInput & vbCrLf
  335.     Else
  336.         strFileInput = strFileInput & strLineInput
  337.     End If
  338. Close #1
  339. StatusBar1.Panels(1).Text = ""
  340. txtEditor.Text = strFileInput
  341. bolScriptNeedsSaving = False
  342. Toolbar1.Buttons(4).Enabled = False
  343. End Sub
  344. Public Sub SaveScript()
  345. If Not (FileSys.FileExists(infile.Text)) Then
  346.   CommonDialog1.InitDir = App.Path
  347.   CommonDialog1.DefaultExt = ".txt"
  348.   CommonDialog1.Filter = "Text Files|*.txt"
  349.   CommonDialog1.ShowOpen
  350. End If
  351. If CommonDialog1.FileName = "" Then Exit Sub
  352. strScriptFilePath = CommonDialog1.FileName
  353. infile.Text = strScriptFilePath
  354. FileSys.DeleteFile (strScriptFilePath)
  355. StatusBar1.Panels(1).Text = "Saving " & strScriptFilePath
  356. Open strScriptFilePath For Binary As #1
  357. Put #1, , txtEditor.Text
  358. Close #1
  359. bolScriptNeedsSaving = False
  360. Toolbar1.Buttons(4).Enabled = False
  361. StatusBar1.Panels(1).Text = ""
  362. End Sub
  363. Private Sub mnuCreatePDF_Click()
  364. CreatePDF
  365. End Sub
  366. Private Sub mnuNewScript_Click()
  367. NewScript
  368. End Sub
  369. Private Sub mnuOpenScript_Click()
  370. OpenScript
  371. End Sub
  372. Private Sub PDF_Error(errCode As Long, errDesc As String)
  373. MsgBox "PDFCreator.dll error #" & errCode & vbCrLf & _
  374.     errDesc
  375. End Sub
  376. Private Sub mnuSave_Click()
  377. SaveScript
  378. End Sub
  379. Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
  380. Select Case Button.Index
  381.     Case 1
  382.         NewScript
  383.     Case 3  ' Open Button
  384.         OpenScript
  385.     Case 4
  386.         SaveScript
  387. End Select
  388. End Sub
  389. Private Sub txtEditor_Change()
  390. If bolScriptNeedsSaving = True Then
  391.     Exit Sub
  392.     bolScriptNeedsSaving = True
  393.     Toolbar1.Buttons(4).Enabled = True
  394. End If
  395. End Sub
  396. Private Sub NewScript()
  397. Dim intResult As Integer
  398. CheckForSave
  399. txtEditor.Text = ""
  400. bolScriptNeedsSaving = False
  401. Toolbar1.Buttons(4).Enabled = False
  402. End Sub
  403. Public Sub CheckForSave()
  404. ' If the script needs to be saved, then prompt the user
  405. '   otherwise, simply continue on to clearing the
  406. '   text box
  407. CancelUnload = False
  408. If bolScriptNeedsSaving = True Then
  409.     intResult = MsgBox("Do you want to save your current script?", vbYesNoCancel, "Script needs saving")
  410.     If intResult = vbCancel Then
  411.         CancelUnload = True
  412.         Exit Sub
  413.     ElseIf intResult = vbYes Then
  414.         SaveScript
  415.     End If
  416. End If
  417. End Sub
  418. Public Sub CreatePDF()
  419. If txtEditor.Text = "" Then
  420.     Exit Sub
  421. End If
  422. Dim PDF
  423. Set PDF = CreateObject("build.Fytek.PDF")
  424. strPDFFilePath = FormatFileName(Trim(outfile.Text))
  425. PDF.setOutFile (strPDFFilePath)
  426. fntFace = fntNum.ItemData(fntNum.ListIndex)
  427. If fntBold = 1 Then
  428.   fntFace = fntFace + 3
  429. End If
  430. If fntItalic = 1 Then
  431.   fntFace = fntFace + 6
  432. End If
  433. PDF.setColumns (numCols.ListIndex + 1)
  434. PDF.setColSpacing (0.5)
  435. PDF.setAlignment (Mid(fntAlign.List(fntAlign.ListIndex), 1, 1))
  436. PDF.setPointSize (fntPoint.ItemData(fntPoint.ListIndex))
  437. PDF.setFontNum (fntFace)
  438. Me.MousePointer = vbHourglass
  439. StatusBar1.Panels(1).Text = "Creating PDF File"
  440. ' Split the string up into individual lines in an array
  441. strScriptArray = Split(txtEditor.Text, vbCrLf)
  442. For i = 0 To UBound(strScriptArray)
  443.   PDF.setPDFCmd (strScriptArray(i))
  444. retval = PDF.buildFytekPDF
  445. Me.MousePointer = vbNormal
  446. If chkPreview.Value = vbChecked Then
  447.     StatusBar1.Panels(1).Text = "Opening Adobe Acrobat"
  448.     frmPDFPreview.Pdf1.src = strPDFFilePath
  449.     frmPDFPreview.Show
  450.     StatusBar1.Panels(1).Text = ""
  451. End If
  452. Set PDF = Nothing
  453. End Sub
  454.